#define MIPI_LAN_RATA_800
// #define MIPI_LAN_RATA_1000
// #define MIPI_LAN_RATA_1500

/*
mipi clk = 71.53 x 2  , 没有数据
*/

static const k_sensor_reg xs9950_mipi4lane_720p_25fps_linear[] = {
    //xs9950_mipi_init
    {0x4300, 0x05},
    {0x4300, 0x15},
    {0x4080, 0x07},
    {0x4119, 0x01},
    {0x0803, 0x00},
    {0x4020, 0x00},
    {0x080e, 0x00},
    {0x080e, 0x20},
    {0x080e, 0x28},
    {0x4020, 0x03},
    {0x0803, 0x1f},         //   zs default 0x0f
    {0x0100, 0x35},
    {0x0104, 0x48},
    {0x0300, 0x3f},
    {0x0105, 0xe1},
    {0x0101, 0x42},
    {0x0102, 0x40},
    {0x0116, 0x3c},
    {0x0117, 0x23},
    {0x0333, 0x23},         //0x23   zs default  0x09
    {0x0336, 0x9e}, 
    {0x0337, 0xd9},
    {0x0338, 0x0a},
    {0x01bf, 0x4e},
    {0x010e, 0x78},
    {0x010f, 0x92},
    {0x0110, 0x70},
    {0x0111, 0x40},      
    // {0x01e1, 0xff},         // zs  default  0xff
    {0x0314, 0x66},
    {0x0130, 0x10},
    {0x0315, 0x23},
    {0x0b64, 0x02},
    {0x01e2, 0x03},
    {0x0b55, 0x80},
    {0x0b56, 0x00},
    {0x0b59, 0x04},
    {0x0b5a, 0x01},
    {0x0b5c, 0x07},
    {0x0b5e, 0x05},
    {0x0b4b, 0x10},
    {0x0b4e, 0x05},
    {0x0b51, 0x21},
    {0x0b30, 0xbc},
    {0x0b31, 0x19},
    {0x0b15, 0x03},
    {0x0b16, 0x03},
    {0x0b17, 0x03},
    {0x0b07, 0x03},
    {0x0b08, 0x05},
    {0x0b1a, 0x10},
    {0x0158, 0x03},
    {0x0a88, 0x20},
    {0x0a61, 0x09},
    {0x0a62, 0x00},
    {0x0a63, 0x0e},
    {0x0a64, 0x00},
    {0x0a65, 0xfc},
    {0x0a67, 0xe5},
    {0x0a69, 0xef},
    {0x0a6b, 0x1b},
    {0x0a6d, 0x2f},
    {0x0a6f, 0x00},
    {0x0a71, 0xc2},
    {0x0a72, 0xff},
    {0x0a73, 0xd0},
    {0x0a74, 0xff},
    {0x0a75, 0x29},
    {0x0a77, 0x57},
    {0x0a78, 0x00},
    {0x0a79, 0x10},
    {0x0a7a, 0x00},
    {0x0a7b, 0xaa},
    {0x0a7d, 0xb2},
    {0x0a7f, 0x24},
    {0x0a80, 0x00},
    {0x0a81, 0x69},
    {0x0a82, 0x00},
    {0x0802, 0x02},
    {0x0501, 0x81},
    {0x0502, 0x0c},         //zs 0x0502 default 0x00
    {0x0b74, 0xfc},
    {0x01dc, 0x01},
    {0x0804, 0x04},
    {0x4018, 0x01},
    {0x0b56, 0x01},
    {0x0b73, 0x02},
    {0x4210, 0x0c},
    {0x420b, 0x2f},     // 上边是一样的

    {0x0504, 0x89},  // bit[4:7] free_run颜色, 取值范围:[0, 8]
    {0x0507, 0x13},     // color bar  bit[0] 彩条滚动
    {0x0503, 0x00},
    {0x0502, 0x0c},        //这几个是读出来的然后在做的配置  zs

    {0x015a, 0x00},         // test pattern config  
    {0x015b, 0x24},
    {0x015c, 0x80},
    {0x015d, 0x16},
    {0x015e, 0xd0},
    {0x015f, 0x02},
    {0x0160, 0xee},
    {0x0161, 0x02},
    {0x0165, 0x00},
    {0x0166, 0x0f},

    {0x4030, 0x15},
    {0x4134, 0x0a},             // zs  default  0x06
    {0x0803, 0x0f},
    {0x4412, 0x00},
    {0x0803, 0x1f},
    {0x10e3, 0x01},             // mipi output en
    {0x10eb, 0x04},             // clk datat lan en 

    {0x50fc, 0x00},             
    {0x50fd, 0x00},
    {0x50fe, 0x0d},
    {0x50ff, 0x59},

    {0x50e4, 0x00},             // lan num 0 :1lna   1 ；2lan   ????
    {0x50e5, 0x00},
    {0x50e6, 0x00},
    {0x50e7, 0x01},

    {0x50f0, 0x00},
    {0x50f1, 0x00},
    {0x50f2, 0x00},
    {0x50f3, 0x32},

    {0x50f0, 0x00},
    {0x50f1, 0x00},
    {0x50f2, 0x00},
    {0x50f3, 0x0f},

    {0x50e8, 0x00},
    {0x50e9, 0x00},
    {0x50ea, 0x00},
    {0x50eb, 0x01},

    {0x5048, 0x00},
    {0x5049, 0x00},
    {0x504a, 0x03},
    {0x504b, 0xff},

    {0x5058, 0x00},
    {0x5059, 0x00},
    {0x505a, 0x00},
    {0x505b, 0x07},

    {0x50e0, 0x00},
    {0x50e1, 0x00},
    {0x50e2, 0x00},
    {0x50e3, 0x00},

    {0x50e0, 0x00},
    {0x50e1, 0x00},
    {0x50e2, 0x00},
    {0x50e3, 0x04},

    {0x50e0, 0x00},
    {0x50e1, 0x00},
    {0x50e2, 0x00},
    {0x50e3, 0x07},
#ifdef MIPI_LAN_RATA_1500
    {0x1003, 0x01},         // mipi pll clk     016f :1.5g      800: 4ed      
    {0x1004, 0x6f},         // mipi pll clk 
#endif

#ifdef MIPI_LAN_RATA_800
    {0x1003, 0x04},         // mipi pll clk     016f :1.5g      800: 4ed      
    {0x1004, 0xed},         // mipi pll clk 
#endif

#ifdef MIPI_LAN_RATA_1000
    {0x1003, 0x01},         // mipi pll clk     016f :1.5g      800: 4ed      
    {0x1004, 0x4a},         // mipi pll clk 
#endif
    {0x1001, 0xe4},
    {0x1000, 0x4d},
    {0x1001, 0xe0},
    {0x1020, 0x1e},
    {0x1020, 0x1f},
#ifdef MIPI_LAN_RATA_1500
    {0x1045, 0xcd},
    {0x1046, 0x0c},
    {0x1047, 0x36},
    {0x1048, 0x0f},
    {0x1049, 0x59},
    {0x104a, 0x07},
    {0x1050, 0xc4},
    {0x1065, 0xcd},
    {0x1066, 0x0c},
    {0x1067, 0x0e},
    {0x1068, 0x0f},
    {0x1069, 0x59},
    {0x106a, 0x07},
    {0x1070, 0xc4},
    {0x1085, 0xcd},
    {0x1086, 0x0c},
    {0x1087, 0x0e},
    {0x1088, 0x0f},
    {0x1089, 0x59},
    {0x108a, 0x07},
    {0x1090, 0xc4},
#endif

#ifdef MIPI_LAN_RATA_1000
    {0x1045, 0xc5},
    {0x1046, 0x40},
    {0x1047, 0x20},
    {0x1048, 0x30},
    {0x1049, 0x4f},
    {0x104a, 0x0a},
    {0x1050, 0x04},
    {0x1065, 0xc5},
    {0x1066, 0x40},
    {0x1067, 0x09},
    {0x1068, 0x30},
    {0x1069, 0x4f},
    {0x106a, 0x0a},
    {0x1070, 0x04},
    {0x1085, 0xc5},
    {0x1086, 0x40},
    {0x1087, 0x09},
    {0x1088, 0x30},
    {0x1089, 0x4f},
    {0x108a, 0x0a},
    {0x1090, 0x04},

#endif

#ifdef MIPI_LAN_RATA_800
    // mipi 800M
    {0x1045, 0xc5},
    {0x1046, 0x70},
    {0x1047, 0x1f},
    {0x1048, 0x18},
    {0x1049, 0x4c},
    {0x104a, 0x0a},
    {0x1050, 0x04},
    {0x1065, 0xc5},
    {0x1066, 0x70},
    {0x1067, 0x09},
    {0x1068, 0x18},
    {0x1069, 0x4c},
    {0x106a, 0x0a},
    {0x1070, 0x04},
    {0x1085, 0xc5},
    {0x1086, 0x70},
    {0x1087, 0x09},
    {0x1088, 0x18},
    {0x1089, 0x4c},
    {0x108a, 0x0a},
    {0x1090, 0x04},
#endif
    {0x1040, 0x0a},  // lane clk pn swap
    {0x1060, 0x0a},  // lane 0 pn swap
    {0x1080, 0x0a},  // lane 1 pn swap

    {0x5004, 0x00},     
    {0x5005, 0x00},
    {0x5006, 0x00},
    {0x5007, 0x01},

    {0x50e8, 0x00},
    {0x50e9, 0x00},
    {0x50ea, 0x00},
    {0x50eb, 0x01},

    // {0x5004, 0x00},      // zs  default  0x06
    // {0x5005, 0x00},

    {0x0800, 0x03},         // zs  default  0x05
    {0x0805, 0x07},         // zs  default  0x05

    {0x4200, 0x02},  // 0x4200=2：选择VINA，0x4200=0：选择VINB，0x4200=4：选择VINC，0x4200=6：选择VIND
    // {0x0111, 0x68},  // 适当调整这三个寄存器，也可增加清晰度和饱和度
    // {0x4202, 0x0e},  // 适当调整这三个寄存器，也可增加清晰度和饱和度
    // {0x4203, 0x04},  // 适当调整这三个寄存器，也可增加清晰度和饱和度
    // {0x0100, 0x38},  // 
    // {0x01ce, 0x00},  // 调整自动曝光 

#if 1
    // xs9950_AHD_720P_25f  
    {0x060b, 0x00},
    {0x0627, 0x14},
    {0x010c, 0x00},
    {0x0800, 0x05},
    {0x0805, 0x05},
    {0x0b50, 0x08},
    {0x0e08, 0x00},
    {0x010d, 0x40},
    {0x010c, 0x01},
    {0x0121, 0x7a},
    {0x0122, 0x6b},
    {0x0130, 0x10},
    {0x01a9, 0x00},
    {0x01aa, 0x04},
    {0x0156, 0x00},
    {0x0157, 0x08},
    {0x0105, 0xc1},  // AHD制式如发现颜色饱和度异常，可选择开关0x105的bit5
    {0x0101, 0x42},
    {0x0102, 0x40},
    {0x0116, 0x3c},
    {0x0117, 0x23},  // AHD制式如发现颜色饱和度异常，可选择打开0x105的bit5，并微调0x117
    {0x01e2, 0x03},
    {0x420b, 0x21},
    {0x0106, 0x80},
    {0x0107, 0x00},
    {0x0108, 0x80},
    {0x0109, 0x00},
    {0x010a, 0x20},
    {0x010b, 0x00},
    {0x011d, 0x17},
    {0x0e08, 0x01},
    {0x0a60, 0x04},
    {0x0a5c, 0xf6},
    {0x0a5d, 0xc0},
    {0x0a5e, 0x2d},
    {0x0a5f, 0x1b},
    {0x0156, 0x50},
    {0x0157, 0x07},
    {0x011d, 0x17},
    {0x0156, 0x00},
    {0x0157, 0x08},
    {0x0503, 0x00},
    {0x015a, 0x8b},
    {0x015b, 0x0e},
    {0x015c, 0x80},
    {0x015d, 0x16},
    {0x015e, 0xd0},
    {0x015f, 0x02},
    {0x0160, 0xee},
    {0x0161, 0x02},
    {0x0165, 0x40},
    {0x0166, 0x0f},
    {0x0A00, 0xFD},
    {0x0A01, 0xFF},
    {0x0A02, 0x00},
    {0x0A03, 0x00},
    {0x0A04, 0x04},
    {0x0A05, 0x00},
    {0x0A06, 0x01},
    {0x0A07, 0x00},
    {0x0A08, 0xFB},
    {0x0A09, 0xFF},
    {0x0A0A, 0xFE},
    {0x0A0B, 0xFF},
    {0x0A0C, 0x07},
    {0x0A0D, 0x00},
    {0x0A0E, 0x03},
    {0x0A0F, 0x00},
    {0x0A10, 0xF7},
    {0x0A11, 0xFF},
    {0x0A12, 0xFA},
    {0x0A13, 0xFF},
    {0x0A14, 0x0B},
    {0x0A15, 0x00},
    {0x0A16, 0x0A},
    {0x0A17, 0x00},
    {0x0A18, 0xF3},
    {0x0A19, 0xFF},
    {0x0A1A, 0xF1},
    {0x0A1B, 0xFF},
    {0x0A1C, 0x0F},
    {0x0A1D, 0x00},
    {0x0A1E, 0x18},
    {0x0A1F, 0x00},
    {0x0A20, 0xEE},
    {0x0A21, 0xFF},
    {0x0A22, 0xDC},
    {0x0A23, 0xFF},
    {0x0A24, 0x14},
    {0x0A25, 0x00},
    {0x0A26, 0x39},
    {0x0A27, 0x00},
    {0x0A28, 0xEB},
    {0x0A29, 0xFF},
    {0x0A2A, 0x98},
    {0x0A2B, 0xFF},
    {0x0A2C, 0x16},
    {0x0A2D, 0x00},
    {0x0A2E, 0x45},
    {0x0A2F, 0x01},
    {0x0A30, 0xEA},
    {0x0A31, 0x01},
    {0x0A60, 0x01},   
    /*针对某些非标AHD72如下配置*/
    {0x0AA7, 0x7A}, 
    {0x0AA8, 0x18}, 	
    {0x0AA9, 0xC0}, 
    {0x0AAA, 0x01}, 
    {0x0AAB, 0xC2}, 
    {0x0AAC, 0x01}, 	
    {0x0AAD, 0x80}, 
    {0x0AAE, 0x43}, 
    {0x0AAF, 0x00}, 	
    {0x0AB0, 0x70}, 
    {0x0AB1, 0x00}, 
    {0x0AB2, 0x1B},	
    {0x0A88, 0x30},	

    //xs9950_mipi_reset_new
    {0x0e08, 0x01},
    // {0x1e08, 0x01},
    // {0x2e08, 0x01},
    // {0x3e08, 0x01},
    {0x5004, 0x00},
    {0x5005, 0x00},
    {0x5006, 0x00},
    {0x5007, 0x00},

    {0x5004, 0x00},
    {0x5005, 0x00},
    {0x5006, 0x00},
    {0x5007, 0x01},
#endif
    {REG_NULL, 0x0},
};
